﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Threading;
using M7;

namespace C7
{
	/// <summary>
	/// Interaction logic for InternetModule.xaml
	/// </summary>
    public partial class PersonalizationModule : UserControl
    {
        private WindowOperations WindowOPs = new WindowOperations();
        public PersonalizationModule()
        {
            this.InitializeComponent();
            WindowOPs.TextBoxesToHandlers(LayoutRoot);
            WindowOPs.WindowToAnimationHandlers(LayoutRoot, true);
        }

        private void PersonolizationM_Loaded(object sender, RoutedEventArgs e)
        {
            Thread thrGenres = new Thread(delegate() { PersonalizationClass.GetGenres(); });
            thrGenres.IsBackground = true;
            thrGenres.Start();

            Thread thrTV = new Thread(delegate() { PersonalizationClass.GetTVChannels(); });
            thrTV.IsBackground = true;
            thrTV.Start();

            Thread thrAC = new Thread(new ThreadStart(() =>
                {
                    PersonalizationClass.GetAC();
                }));
            thrAC.IsBackground = true;
            thrAC.Start();
        }

        private void spOK_MouseDown(object sender, MouseButtonEventArgs e)
        {
            NVote vote = new NVote();
            if (lbMusicGenre.SelectedItem != null)
            {
                vote.Genre = lbMusicGenre.SelectedItem.ToString();
            }
            if (lbACTemp.SelectedItem != null)
            {
                vote.ACTemp = lbACTemp.SelectedItem.ToString();
            }
            if (lbTVChannel.SelectedItem != null)
            {
                vote.TV = lbTVChannel.SelectedItem.ToString();
            }

            Msg SendMsg = new Msg(Properties.Settings.Default.Port, Properties.Settings.Default.TableID);
            SendMsg.obj = vote;
            SendMsg.enumMethod = enumPersonalization.SendVotes;
            TcpConnection.SendingQueue.Enqueue(SendMsg);
        }
    }
}